Skip to content

Fix certifier test permissions - #13473

Merged
bneradt merged 1 commit into
apache:masterfrom
bneradt:fix-certifier-test-permissions
Aug 4, 2026
Merged

Fix certifier test permissions#13473
bneradt merged 1 commit into
apache:masterfrom
bneradt:fix-certifier-test-permissions

Conversation

@bneradt

@bneradt bneradt commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Certifier tests fail in root-run CI because ATS cannot update the
copied serial file or certificate store. Local owner-run tests mask the
problem.

This problem is addressed in this patch by giving the unprivileged ATS
process the required access to the serial file and certificate store in
each certifier scenario.

Copilot AI lite review requested due to automatic review settings August 1, 2026 19:56
@bneradt bneradt added this to the 11.0.0 milestone Aug 1, 2026
@bneradt bneradt self-assigned this Aug 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the certifier gold tests to avoid permission failures when the CI harness runs as root but the ATS process runs unprivileged, ensuring ATS can update the copied CA serial file and certificate store across all certifier scenarios.

Changes:

  • Creates explicit store_path and serial_path variables for each certifier scenario setup.
  • Adjusts permissions on the copied ca-serial.txt and the store/ directory to allow the unprivileged ATS process to write.
Suppressed comments (3)

tests/gold_tests/pluginTest/certifier/certifier.test.py:135

  • Using Setup.RunCommand with an unquoted shell command (and &&) is brittle: paths with spaces/shell metacharacters will break, and this needlessly invokes a shell. Prefer adjusting permissions via Python (os.chmod) in-process.
        Setup.RunCommand(f'chmod a+rw {serial_path} && chmod a+rwx {store_path}')

tests/gold_tests/pluginTest/certifier/certifier.test.py:195

  • Using Setup.RunCommand with an unquoted shell command (and &&) is brittle: paths with spaces/shell metacharacters will break, and this needlessly invokes a shell. Prefer adjusting permissions via Python (os.chmod) in-process.
        Setup.RunCommand(f'chmod a+rw {serial_path} && chmod a+rwx {store_path}')

tests/gold_tests/pluginTest/certifier/certifier.test.py:261

  • Using Setup.RunCommand with an unquoted shell command (and &&) is brittle: paths with spaces/shell metacharacters will break, and this needlessly invokes a shell. Prefer adjusting permissions via Python (os.chmod) in-process.
        Setup.RunCommand(f'chmod a+rw {serial_path} && chmod a+rwx {store_path}')

Comment thread tests/gold_tests/pluginTest/certifier/certifier.test.py Outdated
@cmcfarlen
cmcfarlen self-requested a review August 3, 2026 22:37
cmcfarlen
cmcfarlen previously approved these changes Aug 4, 2026

@cmcfarlen cmcfarlen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd much prefer not to use shell commands for this and just use os.chmod as copilot says. If I understand it correctly, there is a Setup function to run a function at test time that could be used. Minor thing, but avoiding shell commands is always a win. Could also reduce duplication with a function.

Certifier tests fail in root-run CI because ATS cannot update the
copied serial file or certificate store. Local owner-run tests mask the
problem.

This problem is addressed in this patch by giving the unprivileged ATS
process the required access to the serial file and certificate store in
each certifier scenario.
Copilot AI review requested due to automatic review settings August 4, 2026 16:58
@bneradt
bneradt force-pushed the fix-certifier-test-permissions branch from 524b98d to 1280027 Compare August 4, 2026 16:58
@bneradt

bneradt commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

I'd much prefer not to use shell commands for this and just use os.chmod as copilot says. If I understand it correctly, there is a Setup function to run a function at test time that could be used. Minor thing, but avoiding shell commands is always a win. Could also reduce duplication with a function.

Yeah, thanks for pushing back on this. I implemented this now as a Setup lambda function. Can you please re-review?

@cmcfarlen cmcfarlen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely. Thank you for the cleanup!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

tests/gold_tests/pluginTest/certifier/certifier.test.py:36

  • Granting world-writable permissions (0666/0777) is overly permissive and can be rejected by hardened CI environments (and can mask real permission/ownership issues). Prefer least-privilege by changing ownership to the ATS runtime user/group (or the test runner’s effective user/group) and then using tighter modes (e.g., 0660 for the serial file and 0770 for the store directory). If the harness provides a Setup.Chown/Setup.Chgrp utility, use that instead of making files world-writable.
        os.chmod(serial_path, 0o666)
        os.chmod(store_path, 0o777)

tests/gold_tests/pluginTest/certifier/certifier.test.py:36

  • Only the top-level store directory permissions are updated. If Setup.Copy() brings in existing files/subdirectories under store/ with restrictive permissions, ATS may still be unable to overwrite/update those entries, leaving the root-run CI failure unresolved for some scenarios. Consider recursively applying writable permissions to existing contents of store/ (directories and files), or ensure the copied store is empty and created fresh with the intended ownership/permissions.
    def set_permissions() -> None:
        os.chmod(serial_path, 0o666)
        os.chmod(store_path, 0o777)

@bneradt
bneradt merged commit be113cd into apache:master Aug 4, 2026
15 checks passed
@bneradt
bneradt deleted the fix-certifier-test-permissions branch August 4, 2026 18:47
@github-project-automation github-project-automation Bot moved this to For v10.2.0 in ATS v10.2.x Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: For v10.2.0

Development

Successfully merging this pull request may close these issues.

3 participants